home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / general / modelers / geomview / source.lha / Geomview / src / bin / crayola / sgi / crayola.main.c < prev    next >
C/C++ Source or Header  |  1993-10-29  |  3KB  |  130 lines

  1. #include <stdio.h>
  2. #include "geom.h"
  3. #include "color.h"
  4. #include "callbacks.h"
  5. #include "ui.h"
  6. #include "crayola.h"
  7. #include "forms.h"
  8. #include "panel.h"
  9.  
  10.  
  11. main() {
  12.   foreground();
  13.  
  14.   create_the_forms();
  15.  
  16.   fl_init();
  17.  
  18.   fl_set_button(GetButton, 1); 
  19.  
  20.   fl_set_slider_value(IntensitySlide, 1.0);
  21.   fl_set_colorwheel_intensity(colorwheel, 1.0);
  22.   fl_set_slider_value(AlphaSlide, 1.0);
  23.   fl_set_colorwheel_alpha(colorwheel, 1.0);
  24.  
  25.   fl_show_form(MainForm, FL_PLACE_SIZE, TRUE, "Crayola");
  26.  
  27.   init();
  28.  
  29.   uiThaw();
  30.  
  31.   while(1) {
  32.     fl_check_forms();
  33.     checkpipes();
  34.   }
  35. }
  36.  
  37. float get_float_val(FL_OBJECT *obj) {
  38.   float f;
  39.   sscanf(fl_get_input(obj), "%f", &f);
  40.   return f;
  41. }
  42.  
  43.  
  44. void set_float_val(FL_OBJECT *obj, float f) {
  45.   char buf[64];
  46.   sprintf(buf, "%.2f", f);
  47.   fl_set_input(obj, buf);
  48. }
  49.  
  50. void UndoButtonProc(FL_OBJECT *obj, long val) {
  51.   undo();
  52. }
  53.  
  54. void IntensityProc(FL_OBJECT *obj, long val) {
  55.   fl_set_colorwheel_intensity(colorwheel, 
  56.                   fl_get_slider_value(IntensitySlide));
  57.   fl_redraw_object(colorwheel);
  58. }
  59.  
  60. void AlphaProc(FL_OBJECT *obj, long val) {
  61.   fl_set_colorwheel_alpha(colorwheel, fl_get_slider_value(AlphaSlide));
  62.   fl_redraw_object(colorwheel);
  63. }
  64.  
  65. void QuitButtonProc(FL_OBJECT *obj, long val) {
  66.   quit();
  67. }
  68.  
  69. void EliminateButtonProc(FL_OBJECT *obj, long val) {
  70. }
  71.          
  72. /* 
  73.  * UI routines requried by the common routines 
  74.  */
  75. void uiFreeze() {
  76.   fl_freeze_form(MainForm);
  77. }
  78.  
  79. void uiThaw() {
  80.   fl_unfreeze_form(MainForm);
  81. }
  82.  
  83. int uiSet() {
  84.   return fl_get_button(SetButton);
  85. }
  86.  
  87. int uiSetAll() {
  88.   return fl_get_button(SetAllButton);
  89. }
  90.  
  91. int uiGet() {
  92.   return fl_get_button(GetButton);
  93. }
  94.  
  95. int uiEliminateColor() {
  96.   return fl_get_button(EliminateButton);
  97. }
  98.  
  99. void uiChangeColor(ColorA *color) {
  100.   fl_set_colorwheel(colorwheel, &(color->r));
  101.   fl_set_colorwheel_alpha(colorwheel, color->a);
  102.   fl_set_slider_value(IntensitySlide, 
  103.               fl_get_colorwheel_intensity(colorwheel));
  104.   fl_set_slider_value(AlphaSlide, color->a);
  105. }
  106.  
  107. void uiCurrentColor(ColorA *color) {
  108.   fl_get_colorwheel(colorwheel, &(color->r));
  109.   color->a = fl_get_slider_value(AlphaSlide);
  110. }
  111.  
  112. int uiQuery(char *ques1, char *ques2, char *ques3, char *res1, char *res2) 
  113. {
  114.   FL_OBJECT *obj = NULL;
  115.   uiFreeze();
  116.   fl_set_object_label(QuestionText1, ques1);
  117.   fl_set_object_label(QuestionText2, ques2);
  118.   fl_set_object_label(QuestionText3, ques3);
  119.   fl_set_object_label(AnswerButton1, res1);
  120.   fl_set_object_label(AnswerButton2, res2);
  121.   fl_show_form(QueryForm, FL_PLACE_MOUSE, TRUE, "Crayola");
  122.   while (1) {
  123.     obj = fl_do_forms();
  124.     if (obj == AnswerButton1 || obj == AnswerButton2) break;
  125.   }
  126.   fl_hide_form(QueryForm);
  127.   uiThaw();
  128.   return (obj == AnswerButton1 ? 0 : 1);
  129. }
  130.